#include "FsTypes.h"
#include "mConfig.h"
#include "Config.h"
#include "HalStorage.h"
#include "Utils.h"
#include "DBR.h"


static FAT_DBR DBR = {0};

FAT_DBR *GetDBR(void)
{
	return (&DBR);
}

UINT8 DBRInit(UINT8 OemName[])
{
	HalStorage_Read(0, 0, sizeof(FAT_DBR));
	CopyBytes(&DBR, HalStorage_GetBuffer(), sizeof(FAT_DBR));

	if(!IsEqual(OemName, DBR.BS_OEMName, 8))
	{
		return (0);
	}

	return (1);
}

UINT8 DBRFormat(void)
{
	CopyBytes(HalStorage_GetBuffer(), &DBR, sizeof(FAT_DBR));
	HalStorage_Write(0, 0, sizeof(FAT_DBR), TRUE);

	return (1);
}
